using System;
using Cysharp.Threading.Tasks;

namespace EventBus
{
    public partial class Sender
    {
        public async UniTask SendActionAsync<T1, T2, T3, T4, T5, T6, T7, T8>(object callback, int argCount, T1 arg1,
            T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
        {
            switch (argCount)
            {
                case 0:
                {
                    var act = Cast<Func<UniTask>>(callback);
                    await act();
                    break;
                }
                case 1:
                {
                    var act = Cast<Func<T1, UniTask>>(callback);
                    await act(arg1);
                    break;
                }
                case 2:
                {
                    var act = Cast<Func<T1, T2, UniTask>>(callback);
                    await act(arg1, arg2);
                    break;
                }
                case 3:
                {
                    var act = Cast<Func<T1, T2, T3, UniTask>>(callback);
                    await act(arg1, arg2, arg3);
                    break;
                }
                case 4:
                {
                    var act = Cast<Func<T1, T2, T3, T4, UniTask>>(callback);
                    await act(arg1, arg2, arg3, arg4);
                    break;
                }
                case 5:
                {
                    var act = Cast<Func<T1, T2, T3, T4, T5, UniTask>>(callback);
                    await act(arg1, arg2, arg3, arg4, arg5);
                    break;
                }
                case 6:
                {
                    var act = Cast<Func<T1, T2, T3, T4, T5, T6, UniTask>>(callback);
                    await act(arg1, arg2, arg3, arg4, arg5, arg6);
                    break;
                }
                case 7:
                {
                    var act = Cast<Func<T1, T2, T3, T4, T5, T6, T7, UniTask>>(callback);
                    await act(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
                    break;
                }
                case 8:
                {
                    var act = Cast<Func<T1, T2, T3, T4, T5, T6, T7, T8, UniTask>>(callback);
                    await act(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
                    break;
                }
            }
        }
    }
}